/*
 * @Author: chengjiang
 * @Date: 2024-11-05 10:10:21
 * @Description: 
 */
import request from '../utils/axios'

export interface Req {
  type?: number,
  priceType: number,
}

//使用封装好的request
export function getInfo(params: Object) {
  return request({
    url: '/user/info',
    method: 'get',
    params
  })
}

export interface UserInfo {
  account: number,
  userId: string,
  token: string,
}
//返回所有的res信息
export function login<UserInfo>(data: Object) {
  return request<UserInfo>({
    url: '/back/auth/user/login',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}
export function logout<UserInfo>() {
  return request<UserInfo>({
    url: '/back/auth/user/logout',
    method: 'post',
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}


// 图片上传

export interface Photo {
  id?: number,
  priceType: number, // 0: 看价盘，1: customer临售盘
  type: number, // 0: logo, 1: qrcode, 2: wxcode,  // 4: customer_photo.
  content: string,
}

export function SavePhoto(data: Photo) {
  return request({
    url: '/back/basic/setting/resource/config/add',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}
export function UpdatePhoto(id:number, data: Photo) {
  return request({
    url: `/back/basic/setting/resource/config/update/${id}`,
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}

export interface GetPhotoReq {
  type?: number,
  priceType: number,
}

export function GetPhoto(data: GetPhotoReq) {
  return request<Array<Photo>>({
    url: '/back/basic/setting/resource/config/list',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}


// 金价涨跌调整
export interface GoldPrice {
  id: number,
  priceType: number, // 0: 看价盘，1: customer临售盘
  currencyCode: string, // 币种英文代码
  currencyName: string, // 币种中文名称
  recyclePrice: number, // 回收价
  sellPrice: number, // 销售价
}

export function SaveGoldSetting(data: GoldPrice) {
  return request({
    url: '/back/basic/setting/gold/config/add',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}
export function UpdateGoldSetting(id:number, data: GoldPrice) {
  return request({
    url: `/back/basic/setting/gold/config/update/${id}`,
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}
export function ListGoldSetting(data: Req) {
  return request<Array<GoldPrice>>({
    url: '/back/basic/setting/gold/config/list',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}


// 开闭盘：
export interface OpenClose {
  id: number,
  status: number, // 0: open, 1: close
  effectHour: number,
  updateTime?: string,
}

export function OpenClose(data: OpenClose) {
  return request({
    url: '/back/basic/setting/quotation/time/save',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}
export function GetOpenClose() {
  return request<OpenClose>({
    url: '/back/basic/setting/quotation/time/get',
    method: 'get',
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}